<template>
  <div class="contrast-box">
    <div class="contrast">
      <ul class="c-navTab">
        <li
          v-for="(item,index) in tabs"
          :class="{active:index == num}"
          @click="tab(index)"
          :key="index"
        >
          {{item}}
       </li>
      </ul>
      <div class="c-main-box-box">
        <div class="c-main-box" v-bind:class="{translateX: num===1}">
          <div class="c-main">
            <div class="c-left">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title"><em></em>各{{levelByte.lower}}园所<span>出勤情况</span>横向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(7, 111)">最近7天</li>
                    <li class="btn1" @click="timeSlot(30, 111)">最近30天</li>
                    <li>
                      <date-picker @getData="getData(arguments, 111)"></date-picker>
                    </li>
                  </ul>
                </div>
                <div>
                  <h3>数据对比项（多选）</h3>
                  <el-checkbox :tabList="cityList" @getCheckBox="getCheckBox(arguments, 111)"></el-checkbox>
                </div>
              </div>
              <div class="echarts-box">
                <el-line
                  :xData="dayWork.workDate"
                  :data="dayWork.workData"
                  :max="100"
                  :xSize="8"
                  v-if="dayWork.summary !== '暂无总结'"
                >
                </el-line>
                <no-data v-else :item="'出勤情况'" />
              </div>
              <el-summary :data="dayWork.summary"></el-summary>
            </div>
            <div class="c-right">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title"><em></em>单个{{levelByte.lower}}<span>出勤情况</span>纵向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(90, 112)">最近3个月</li>
                    <li>
                      <month-range @getMonthRange="getMonthRange(arguments, 112)"></month-range>
                    </li>
                  </ul>
                </div>
                <div>
                  <h3>【{{this.areaName}}】选择{{levelByte.lower}}（单选）</h3>
                  <el-radio :tabList="cityList" @getRadio="getRadio(arguments, 112)"></el-radio>
                </div>
              </div>
              <h3 class="locationTitle iconfont">{{workL.cityList[0]}}</h3>
              <div class="echarts-box">
                <bars
                  :xData="monthWork.xData"
                  :data="monthWork.data"
                  :color="monthWork.color"
                  :yName="monthWork.yName"
                  :grid="monthWork.grid"
                  :addYAxis="monthWork.addYAxis"
                  :yPadding="monthWork.yPadding"
                  :max="monthWork.max"
                  :rotate="0"
                  :xSize="8"
                  :barGap="0.5"
                  :barWidth="12"
                  v-if="monthWork.summary !== '暂无总结'"
                ></bars>
                <no-data v-else :item="'出勤情况'" />
              </div>
              <el-summary :data="monthWork.summary"></el-summary>
            </div>
          </div>
          <div class="c-main c-main-second">
            <div class="c-left">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title"><em></em>各{{levelByte.lower}}园所<span>晨检概况</span>横向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(7, 121)">最近7天</li>
                    <li class="btn1" @click="timeSlot(30, 121)">最近30天</li>
                    <li>
                      <date-picker @getData="getData(arguments, 121)"></date-picker>
                    </li>
                  </ul>
                </div>
                <div>
                  <h3>数据对比项（多选）</h3>
                  <el-checkbox :tabList="cityList" @getCheckBox="getCheckBox(arguments, 121)"></el-checkbox>
                </div>
              </div>
              <div class="echarts-box">
                <radar
                  :max="dayMCheck.max"
                  :data="dayMCheck.data"
                  v-if="dayMCheck.summary !== '暂无总结'"
                ></radar>
                <no-data v-else :item="'晨检概况'" />
              </div>
              <el-summary :data="dayMCheck.summary"></el-summary>
            </div>
            <div class="c-right">
              <div class="filter-box">
                <div class="title-date">
                  <h3 class="title"><em></em>单个{{levelByte.lower}}<span>晨检概况</span>纵向对比</h3>
                  <ul>
                    <li class="btn1 on" @click="timeSlot(90, 122)">最近3个月</li>
                    <li>
                      <month-range @getMonthRange="getMonthRange(arguments, 122)"></month-range>
                    </li>
                  </ul>
                </div>
                <div>
                  <h3>【{{areaName}}】选择{{levelByte.lower}}（单选）</h3>
                  <el-radio :tabList="cityList" @getRadio="getRadio(arguments, 122)"></el-radio>
                </div>
              </div>
              <h3 class="locationTitle iconfont">{{mCheckL.cityList[0]}}</h3>
              <div class="echarts-box">
                <bars
                  :xData="monthMCheck.xData"
                  :data="monthMCheck.data"
                  :color="monthMCheck.color"
                  :grid="monthMCheck.grid"
                  :yName="monthMCheck.yName"
                  :rotate="0"
                  :xSize="8"
                  :barGap="0.5"
                  :barWidth="12"
                  v-if="monthMCheck.summary !== '暂无总结'"
                ></bars>
                <no-data v-else :item="'晨检概况'" />
              </div>
              <el-summary :data="monthMCheck.summary"></el-summary>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import ElCheckbox from '@/common/elementUi/ElCheckbox'
import DatePicker from '@/common/elementUi/EldatePicker'
import ElRadio from '@/common/elementUi/ElRadio'
import ElLine from '@/common/echarts/Line'
import MonthRange from '@/common/layerUi/MonthRange'
import BarBar from '@/common/echarts/expand/BarBar'
import {timeSlot} from '@/common/customTime/customTime'
import Radar from '@/common/echarts/Radar'
import http from '@/common/axios/http'
import api from '@/common/axios/api'
import Bars from '@/common/echarts/expand/Bars'
import ElSummary from '@/common/summary/Summary'
export default {
  name: 'HealthyContrast',
  components: {
    ElCheckbox,
    DatePicker,
    ElRadio,
    ElLine,
    MonthRange,
    BarBar,
    Radar,
    Bars,
    ElSummary
  },
  data () {
    return {
      tabs: ['出勤情况', '晨检情况'],
      num: 0,
      // 首次登陆
      isOnce: true,
      // 出勤情况横向对比
      workC: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        cityList: [],
        data: []
      },
      // 出勤情况纵向对比
      workL: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        cityList: [],
        data: []
      },
      // 晨检情况横向对比
      mCheckC: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        cityList: [],
        data: []
      },
      // 出勤情况纵向对比
      mCheckL: {
        time: {
          startTime: '2018-07-29',
          endTime: '2018-07-30'
        },
        cityList: [],
        data: []
      },
      dayWork: {
        summary: '...',
        workDate: ['暂无数据'],
        workData: [
          {
            name: '杭州市',
            value: [0, 0, 0, 0, 0, 0, 0]
          }, {
            name: '宁波市',
            value: [0, 0, 0, 0, 0, 0, 0]
          }, {
            name: '安康市',
            value: [0, 0, 0, 0, 0, 0, 0]
          }
        ]
      },
      // 出勤情况纵向对比
      monthWork: {
        summary: '...',
        addYAxis: {
          min: 0,
          name: '出勤人数（人）',
          position: 'right',
          nameTextStyle: {
            color: '#536390',
            padding: [0, 60, 0, 0]
          },
          type: 'value',
          splitNumber: 10,
          splitLine: {
            show: true,
            lineStyle: {
              color: 'rgba(57, 121, 211, 0)'
            }
          },
          splitArea: {
            show: true,
            areaStyle: {
              color: ['rgba(24, 61, 111, 0)', 'rgba(24, 61, 111, 0)']
            }
          },
          axisLine: {
            show: false
          },
          axisLabel: {
            textStyle: {
              color: '#536390'
            }
          }
        },
        xData: ['2018-06月', '2018-07月', '2018-08月', '2018-09月'],
        data:
        [
          {
            name: '最大出勤率',
            value: [0, 0, 0, 0]
          },
          {
            name: '最低出勤率',
            value: [0, 0, 0, 0]
          },
          {
            name: '最大出勤人数',
            yAxisIndex: 1,
            value: [0, 0, 0, 0]
          },
          {
            name: '最低出勤人数',
            yAxisIndex: 1,
            value: [0, 0, 0, 0]
          }
        ],
        yName: '出勤率（%）',
        yPadding: [0, 0, 0, 30],
        max: 100,
        color: ['#ffe98f', '#53e9ee', '#7193ff', '#315bff'],
        grid: {
          top: '20%',
          left: '0%',
          right: '0%',
          bottom: '10%',
          containLabel: true
        }
      },
      // 晨检情况横向对比
      dayMCheck: {
        summary: '...',
        max: 10,
        data: [
          {
            value: [0, 0, 0, 0],
            name: '杭州市'
          },
          {
            value: [0, 0, 0, 0],
            name: '宁波市'
          },
          {
            value: [0, 0, 0, 0],
            name: '安康市'
          }
        ]
      },
      // 晨检情况纵向对比
      monthMCheck: {
        summary: '...',
        xData: ['2018-06月', '2018-07月', '2018-08月', '2018-09月'],
        data:
        [
          {
            name: '体温异常人次',
            value: [0, 0, 0, 0]
          },
          {
            name: '需要加餐人次',
            value: [0, 0, 0, 0]
          },
          {
            name: '需要服药人次',
            value: [0, 0, 0, 0]
          },
          {
            name: '需要观察人次',
            value: [0, 0, 0, 0]
          }
        ],
        color: ['#ffe98f', '#53e9ee', '#7193ff', '#315bff'],
        yName: '人数（人）',
        grid: {
          top: '20%',
          left: '0%',
          right: '0%',
          bottom: '10%',
          containLabel: true
        }
      }
    }
  },
  computed: {
    levelByte () {
      let obj = {
        curr: '省',
        lower: '市'
      }
      switch (this.areaLevel) {
        case '省级':
          obj = {
            curr: '省',
            lower: '市'
          }
          break
        case '市级':
          obj = {
            curr: '市',
            lower: '区'
          }
          break
        case '区级':
          obj = {
            curr: '区',
            lower: '园'
          }
          break
      }
      return obj
    },
    ...mapGetters({
      // 当前区域名称
      areaName: 'area',
      // 区域等级
      areaLevel: 'areaLevel',
      // 选择对比项
      cityList: 'areaMapList'
    })
  },
  async mounted () {
    // 初始化所有边框样式
    this.$common.border(window.$('.contrast'))
    await this.$store.dispatch('fetchMapFeatures')

    this.workC.cityList = this.$store.getters.areaMapList.slice(0, 3)
    this.workL.cityList = this.$store.getters.areaMapList.slice(0, 1)
    this.mCheckC.cityList = this.$store.getters.areaMapList.slice(0, 3)
    this.mCheckL.cityList = this.$store.getters.areaMapList.slice(0, 1)

    this.timeSlot(7, 111)
    this.timeSlot(90, 112)
    window.$('.title-date li').click(function () {
      window.$(this).closest('li').addClass('on').siblings().removeClass('on')
    })
  },
  watch: {
    // 出勤情况横向对比
    'workC.time': {
      deep: true,
      handler: function (newVal) {
        this.getWorkC(newVal)
      }
    },
    'workC.cityList': {
      deep: true,
      handler: function (newVal) {
        this.dayWorkC()
      }
    },
    // 出勤情况纵向对比
    'workL.time': {
      deep: true,
      handler: function (newVal) {
        this.getWorkL(newVal)
      }
    },
    'workL.cityList': {
      deep: true,
      handler: function (newVal) {
        this.dayWorkL()
      }
    },
    // 晨检概况横向对比
    'mCheckC.time': {
      deep: true,
      handler: function (newVal) {
        this.getMCheckC(newVal)
      }
    },
    'mCheckC.cityList': {
      deep: true,
      handler: function (newVal) {
        this.dayMCheckC()
      }
    },
    // 晨检概况纵向对比
    'mCheckL.time': {
      deep: true,
      handler: function (newVal) {
        this.getMCheckL(newVal)
      }
    },
    'mCheckL.cityList': {
      deep: true,
      handler: function (newVal) {
        this.dayMCheckL()
      }
    }
  },
  methods: {
    // 出勤情况横向对比
    getWorkC: async function (newVal) {
      let res
      switch (this.areaLevel) {
        case '省级':
          res = await http.get(api.provinceAttendDetail, {
            aeDate: newVal.startTime,
            bDate: newVal.endTime,
            provinceName: this.areaName
          })
          break
        case '市级':
          res = await http.get(api.cityAttendDetail, {
            aeDate: newVal.startTime,
            bDate: newVal.endTime,
            cityName: this.areaName
          })
          break
        case '区级':
          res = await http.get(api.districtattenddetail, {
            aeDate: newVal.startTime,
            bDate: newVal.endTime,
            districtName: this.areaName
          })
          break
      }
      if (res.data) {
        this.workC.data = res.data.data
        this.dayWorkC()
      }
    },
    // 出勤情况横向对比-数据
    dayWorkC () {
      // 所有检测时间节点
      const filterData = []
      let forCheckDate = []
      for (let i = 0, len = this.workC.cityList.length; i < len; i++) {
        const result = this.workC.data.filter((item) => {
          return item.cityName === this.workC.cityList[i] || item.districtName === this.workC.cityList[i] || item.gardenName === this.workC.cityList[i]
        })
        forCheckDate = forCheckDate.concat(result)
      }
      if (!forCheckDate.length) {
        forCheckDate = [{
          attendCount: 0,
          checkDate: '暂无数据',
          cityName: '',
          perenct: '0',
          totalCount: 0
        }]
      }
      let checkDate = this.$common.excludeRepeat(forCheckDate, 'checkDate')
      const $checkDate = checkDate
      checkDate = checkDate.map((item) => {
        let month, day
        item.substring(5, 6) !== '0' ? month = item.substring(5, 7) : month = item.substring(6, 7)
        item.substring(8, 9) !== '0' ? day = item.substring(8, 10) : day = item.substring(9, 10)
        return item.substring(2, 4) + '年' + month + '月' + day + '日'
      })
      for (let i = 0, len = this.workC.cityList.length; i < len; i++) {
        let iResult = []
        if ($checkDate.length) {
          const citRes = forCheckDate.filter((item) => {
            return item.cityName === this.workC.cityList[i] || item.districtName === this.workC.cityList[i] || item.gardenName === this.workC.cityList[i]
          })
          for (let j = 0, len = $checkDate.length; j < len; j++) {
            const cheRes = citRes.filter((item) => {
              return item.checkDate === $checkDate[j]
            })
            if (cheRes.length) {
              iResult.push(parseFloat(cheRes[0].perenct))
            } else {
              iResult.push(0)
            }
          }
          if ($checkDate[0] === '暂无数据') {
            checkDate = ['暂无数据']
          }
        } else {
          checkDate = ['暂无数据']
          iResult = [0]
        }
        filterData.push({
          name: this.workC.cityList[i],
          value: iResult
        })
      }
      this.dayWork.workDate = checkDate
      this.dayWork.workData = filterData
      // 总结语
      let summary = ''
      if ($checkDate[0] !== '暂无数据') {
        const summarySort = forCheckDate.sort((p1, p2) => {
          return parseFloat(p2.perenct) * 100 - parseFloat(p1.perenct) * 100
        })
        let summaryName = ''
        switch (this.areaLevel) {
          case '省级':
            summaryName = 'cityName'
            break
          case '市级':
            summaryName = 'districtName'
            break
          case '区级':
            summaryName = 'gardenName'
            break
        }
        summary = '在全' + this.levelByte.curr +'范围下，' + this.workC.cityList.join('、') + '在' + this.workC.time.startTime + '至' + this.workC.time.endTime + '的对比情况如下：<br>最高出勤率：发生在' + summarySort[0].checkDate.substring(0, 11) + '的' + summarySort[0][summaryName] + ' 最低出勤率：发生在' + summarySort[summarySort.length - 1].checkDate.substring(0, 11) + '的' + summarySort[summarySort.length - 1][summaryName] // eslint-disable-line
      } else {
        summary = '暂无总结'
      }
      this.dayWork.summary = summary
    },
    // 出勤情况纵向对比
    getWorkL: async function (newVal) {
      let res
      switch (this.areaLevel) {
        case '省级':
          res = await http.get(api.monthprovinceattend, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            provinceName: this.areaName
          })
          break
        case '市级':
          res = await http.get(api.monthcityattend, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            cityName: this.areaName
          })
          break
        case '区级':
          res = await http.get(api.monthdistrictattend, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            districtName: this.areaName
          })
          break
      }
      if (res.data) {
        this.workL.data = res.data.data
        const list = this.cityList
        let name = ''
        switch (this.areaLevel) {
          case '省级':
            name = 'cityName'
            break
          case '市级':
            name = 'districtName'
            break
          case '区级':
            name = 'gardenName'
            break
        }
        let arr = []
        for (let i = 0, len = list.length; i < len; i++) {
          const result = this.workL.data.filter((item) => {
            return item[name] === list[i]
          })
          if (!result.length) {
            arr.push({
              cityName: list[i],
              months: [{
                absentCount: 0,
                date: '',
                leaveCount: 0,
                maxAttendPrc: 0,
                minAttendPrc: 0
              }]
            })
          }
        }
        this.workL.data = this.workL.data.concat(arr)
        this.dayWorkL()
      }
    },
    // 出勤情况纵向对比-数据
    dayWorkL () {
      const filterData = this.workL.data.filter((p) => {
        return p.cityName === this.workL.cityList[0] || p.districtName === this.workL.cityList[0] || p.gardenName === this.workL.cityList[0]
      })
      if (filterData.length < 1) return
      const $arr = filterData[0].months
      const $obj = {
        xData: [],
        data: [
          {
            name: '最大出勤率',
            value: []
          },
          {
            name: '最低出勤率',
            value: []
          },
          {
            name: '最大出勤人数',
            yAxisIndex: 1,
            value: []
          },
          {
            name: '最低出勤人数',
            yAxisIndex: 1,
            value: []
          }
        ]
      }
      for (let i = 0, len = $arr.length; i < len; i++) {
        let month = '暂无数据'
        if ($arr[i].date !== '') {
          month = $arr[i].date.substring(0, 7) + '月'
        }
        $obj.xData.push(month)
        $obj.data[0].value.push($arr[i].minAttendPrc)
        $obj.data[1].value.push($arr[i].maxAttendPrc)
        $obj.data[2].value.push($arr[i].absentCount)
        $obj.data[3].value.push($arr[i].leaveCount)
      }
      this.monthWork = window.$.extend({}, this.monthWork, $obj)
      // 总结语
      let summary = ''
      if ($arr[0].date) {
        const summarySort = {
          '最高出勤率': this.$common.compareSort($arr, 'maxAttendPrc'),
          '最低出勤率': this.$common.compareSort($arr, 'minAttendPrc'),
          '月请假人次降序': this.$common.compareSort($arr, 'leaveCount'),
          '月出勤人次降序': this.$common.compareSort($arr, 'absentCount')
        }
        summary = this.workL.cityList[0] + '，在最近3个月的出勤情况对比如下：<br>最高出勤率：发生在' + summarySort['最高出勤率'][0].date.substring(0, 7) + '月份 最低出勤率：发生在' + summarySort['最低出勤率'][summarySort['最低出勤率'].length - 1].date.substring(0, 7) + '月份<br>月请假人次最高：发生在' + summarySort['月请假人次降序'][0].date.substring(0, 7) + '月份 月请假人次最低：发生在' + summarySort['月请假人次降序'][summarySort['月请假人次降序'].length - 1].date.substring(0, 7) + '月份<br>月出勤人次最高：发生在' + summarySort['月出勤人次降序'][0].date.substring(0, 7) + '月份 月出勤人次最低：发生在' + summarySort['月出勤人次降序'][summarySort['月出勤人次降序'].length - 1].date.substring(0, 7) + '月份'
        // 都为0
        if (this.monthWork.data[0].value.findIndex(v => v !== 0) === -1 && this.monthWork.data[2].value.findIndex(v => v !== 0) === -1) {
          summary = '暂无总结'
        }
      } else {
        summary = '暂无总结'
      }
      this.monthWork.summary = summary
    },
    // 晨检情况横向对比
    getMCheckC: async function (newVal) {
      let res
      switch (this.areaLevel) {
        case '省级':
          res = await http.get(api.provinceMCheck, {
            aeCheckDay: newVal.startTime,
            bCheckDay: newVal.endTime,
            provinceName: this.areaName
          })
          break
        case '市级':
          res = await http.get(api.cityMCheck, {
            aeCheckDay: newVal.startTime,
            bCheckDay: newVal.endTime,
            cityName: this.areaName
          })
          break
        case '区级':
          res = await http.get(api.districtMCheck, {
            aeCheckDay: newVal.startTime,
            bCheckDay: newVal.endTime,
            districtName: this.areaName
          })
          break
      }
      if (res.data) {
        this.mCheckC.data = res.data.data
        this.dayMCheckC()
      }
    },
    dayMCheckC () {
      const arr = []
      const summaryFilter = []
      for (let i = 0, len = this.mCheckC.cityList.length; i < len; i++) {
        const result = this.mCheckC.data.filter((item) => {
          return item.cityName === this.mCheckC.cityList[i] || item.districtName === this.mCheckC.cityList[i] || item.gardenName === this.mCheckC.cityList[i]
        })
        if (result.length) {
          summaryFilter.push(this.mCheckC.cityList[i])
          arr.push({
            name: this.mCheckC.cityList[i],
            value: [result[0].warnCount, result[0].jcCount, result[0].fyCount, result[0].gcCount]
          })
        } else {
          arr.push({
            name: this.mCheckC.cityList[i],
            value: [0, 0, 0, 0]
          })
        }
      }
      this.dayMCheck.data = arr
      // 获取最大值
      const max = []
      for (let i = 0, len = arr.length; i < len; i++) {
        max.push(Math.max(...arr[i].value))
      }
      this.dayMCheck.max = 1
      if (Math.max(...max) > this.dayMCheck.max) {
        this.dayMCheck.max = Math.max(...max) + Math.max(...max) * 0.2 + this.dayMCheck.max
      }
      // 总结语
      let summary = ''
      if (summaryFilter.length) {
        const summarySort = {
          '体温异常人次': arr.sort((p1, p2) => { return p2.value[0] - p1.value[0] }),
          '需要加餐人次': arr.sort((p1, p2) => { return p2.value[1] - p1.value[1] }),
          '需要服药人次': arr.sort((p1, p2) => { return p2.value[2] - p1.value[2] }),
          '需要观察人次': arr.sort((p1, p2) => { return p2.value[3] - p1.value[3] })
        }
        summary = '在全' + this.levelByte.curr +'范围下，' + this.mCheckC.cityList.join('、') + '在' + this.mCheckC.time.startTime + '至' + this.mCheckC.time.endTime + '的对比情况如下：<br>累计体温异常人次最高：' + summarySort['体温异常人次'][0].name + ' 累计体温异常人次最低：' + summarySort['体温异常人次'][summarySort['体温异常人次'].length - 1].name + '<br>累计需要观察人次最高：' + summarySort['需要加餐人次'][0].name + ' 累计需要观察人次最低：' + summarySort['需要加餐人次'][summarySort['需要加餐人次'].length - 1].name + '<br>累计需要服药人次最高：' + summarySort['需要服药人次'][0].name + ' 累计需要服药人次最低：' + summarySort['需要服药人次'][summarySort['需要服药人次'].length - 1].name + '<br>累计需要加餐人次最高：' + summarySort['需要观察人次'][0].name + ' 累计需要加餐人次最低：' + summarySort['需要观察人次'][summarySort['需要观察人次'].length - 1].name // eslint-disable-line
      } else {
        summary = '暂无总结'
      }
      this.dayMCheck.summary = summary
    },
    // 晨检情况纵向对比
    getMCheckL: async function (newVal) {
      let res
      switch (this.areaLevel) {
        case '省级':
          res = await http.get(api.monthprovincecheck, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            provinceName: this.areaName
          })
          break
        case '市级':
          res = await http.get(api.monthcitycheck, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            cityName: this.areaName
          })
          break
        case '区级':
          res = await http.get(api.monthdistrictcheck, {
            aeMonth: newVal.startTime,
            bMonth: newVal.endTime,
            districtName: this.areaName
          })
          break
      }
      if (res.data) {
        this.mCheckL.data = res.data.data
        const list = this.cityList
        let name = ''
        switch (this.areaLevel) {
          case '省级':
            name = 'cityName'
            break
          case '市级':
            name = 'districtName'
            break
          case '区级':
            name = 'gardenName'
            break
        }
        let arr = []
        for (let i = 0, len = list.length; i < len; i++) {
          const result = this.mCheckL.data.filter((item) => {
            return item[name] === list[i]
          })
          if (!result[0]) {
            arr.push({
              cityName: list[i],
              months: [{
                warnCount: 0,
                date: '',
                jcCount: 0,
                fyCount: 0,
                gcCount: 0
              }]
            })
          }
        }
        this.mCheckL.data = this.mCheckL.data.concat(arr)
        this.dayMCheckL()
      }
    },
    // 晨检情况纵向对比-数据
    dayMCheckL () {
      const filterData = this.mCheckL.data.filter((p) => {
        return p.cityName === this.mCheckL.cityList[0] || p.districtName === this.mCheckL.cityList[0] || p.gardenName === this.mCheckL.cityList[0]
      })
      if (filterData.length < 1) return
      const $arr = filterData[0].months
      const $obj = {
        xData: [],
        data: [
          {
            name: '体温异常人次',
            value: []
          },
          {
            name: '需要加餐人次',
            value: []
          },
          {
            name: '需要服药人次',
            value: []
          },
          {
            name: '需要观察人次',
            value: []
          }
        ]
      }
      for (let i = 0, len = $arr.length; i < len; i++) {
        let month = '暂无数据'
        if ($arr[i].date !== '') {
          month = $arr[i].date.substring(0, 7) + '月'
        }
        $obj.xData.push(month)
        $obj.data[0].value.push($arr[i].warnCount)
        $obj.data[1].value.push($arr[i].jcCount)
        $obj.data[2].value.push($arr[i].fyCount)
        $obj.data[3].value.push($arr[i].gcCount)
      }
      this.monthMCheck = window.$.extend({}, this.monthMCheck, $obj)
      // 总结语
      let summary = ''
      if ($arr[0].date) {
        const summarySort = {
          '体温异常人次': this.$common.compareSort($arr, 'warnCount'),
          '需要加餐人次': this.$common.compareSort($arr, 'jcCount'),
          '需要服药人次': this.$common.compareSort($arr, 'fyCount'),
          '需要观察人次': this.$common.compareSort($arr, 'gcCount')
        }
        summary = '在全' + this.levelByte.curr +'范围下，' + this.mCheckL.cityList.join('、') + '在' + this.mCheckC.time.startTime + '至' + this.mCheckC.time.endTime + '的对比情况如下：<br>累计体温异常人次最高：' + summarySort['体温异常人次'][0].date.substring(0, 7) + '月 累计体温异常人次最低：' + summarySort['体温异常人次'][summarySort['体温异常人次'].length - 1].date.substring(0, 7) + '月<br>累计需要观察人次最高：' + summarySort['需要加餐人次'][0].date.substring(0, 7) + '月 累计需要观察人次最低：' + summarySort['需要加餐人次'][summarySort['需要加餐人次'].length - 1].date.substring(0, 7) + '月<br>累计需要服药人次最高：' + summarySort['需要服药人次'][0].date.substring(0, 7) + '月 累计需要服药人次最低：' + summarySort['需要服药人次'][summarySort['需要服药人次'].length - 1].date.substring(0, 7) + '月<br>累计需要加餐人次最高：' + summarySort['需要观察人次'][0].date.substring(0, 7) + '月 累计需要加餐人次最低：' + summarySort['需要观察人次'][summarySort['需要观察人次'].length - 1].date.substring(0, 7) + '月' // eslint-disable-line
      } else {
        summary = '暂无总结'
      }
      this.monthMCheck.summary = summary
    },
    // 对比数据标签切换
    tab (index) {
      this.num = index
      if (index === 1 && this.isOnce) {
        this.timeSlot(7, 121)
        this.timeSlot(90, 122)
        this.isOnce = !this.isOnce
      }
    },
    // 最近一段时间
    timeSlot (d, i) {
      const res = timeSlot(d)
      switch (i) {
        case 111:
          this.workC.time.startTime = res.t1
          this.workC.time.endTime = res.t2
          break
        case 112:
          this.workL.time.startTime = res.t1
          this.workL.time.endTime = res.t2
          break
        case 121:
          this.mCheckC.time.startTime = res.t1
          this.mCheckC.time.endTime = res.t2
          break
        case 122:
          this.mCheckL.time.startTime = res.t1
          this.mCheckL.time.endTime = res.t2
          break
      }
    },
    // 开始结束时间(天)
    getData (d, i) {
      const res = d[0]
      switch (i) {
        case 111:
          this.workC.time.startTime = res.t1
          this.workC.time.endTime = res.t2
          break
        case 121:
          this.mCheckC.time.startTime = res.t1
          this.mCheckC.time.endTime = res.t2
          break
      }
    },
    // 城市多选
    getCheckBox (d, i) {
      const res = d[0]
      switch (i) {
        case 111:
          this.workC.cityList = res
          break
        case 121:
          this.mCheckC.cityList = res
          break
      }
    },
    // 开始结束时间(月)
    getMonthRange (d, i) {
      const res = d[0]
      switch (i) {
        case 112:
          this.workL.time.startTime = res.t1
          this.workL.time.endTime = res.t2
          break
        case 122:
          this.mCheckL.time.startTime = res.t1
          this.mCheckL.time.endTime = res.t2
          break
      }
    },
    // 城市单选
    getRadio (d, i) {
      const res = []
      res.push(d[0])
      switch (i) {
        case 112:
          this.workL.cityList = res
          break
        case 122:
          this.mCheckL.cityList = res
          break
      }
    }
  }
}
</script>

<style lang="stylus" scoped>

</style>
